/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-12 09:58:14
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-17 17:28:22
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/components/animation_text.dart';
import 'package:flutter_data_center/model/home/module_model.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';

import '../../../../constants.dart';

class MenuItem extends StatelessWidget {
  const MenuItem({
    Key key,
    this.module,
  }) : super(key: key);
  final ModuleModel module;

  @override
  Widget build(BuildContext context) => Container(
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(defaultRadius),
          boxShadow: [
            BoxShadow(
              offset: Offset(0, 0),
              blurRadius: 5,
              color: Color.fromRGBO(0, 0, 0, 0.08),
            ),
          ],
        ),
        child: Material(
          color: Colors.transparent,
          child: InkWell(
            borderRadius: BorderRadius.circular(defaultRadius),
            onTap: () {
              Get.toNamed("/${module.module}");
            },
            child: Padding(
              padding:
                  EdgeInsets.only(left: 16, right: 10, top: 16, bottom: 10),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    "${module.menu}",
                    style: TextStyle(
                      fontSize: 14,
                    ),
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: [
                      AnimText(
                        number: module.count ?? 0,
                        style: TextStyle(
                          fontSize: 16,
                          color: Theme.of(context).primaryColor,
                        ),
                      ),
                      Spacer(),
                      SvgPicture.asset(
                        "assets/icon/${module.svg}",
                        width: 30,
                        height: 30,
                        color: Color(0xff333333),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),
        ),
      );
}
